﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TV_2013.Handle;
using TV_2013.Model;

namespace TV_2013.View.Feature2.DrawText
{
    public partial class ChooseLetter : PhoneApplicationPage
    {
        ReadData readData = new ReadData("Data/DrawTextLetter.xml");
        private int n;
        DrawTextLetterModel dtlModel = new DrawTextLetterModel();

        public ChooseLetter()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            n = Int32.Parse(NavigationContext.QueryString["n"]);
            dtlModel = readData.GetDrawTextLetterDataByAttribute(n);

            for (int i = 0; i < n; ++i)
            {
                Button btntxt = new Button();
                btntxt.Content = dtlModel.ArrayText[i];
                btntxt.Height = 124;
                btntxt.Width = 124;
                btntxt.FontSize = 60;
                btntxt.BorderThickness = new System.Windows.Thickness(0, 0, 0, 5);
                btntxt.Click += btntxt_Click;
                panelChooseLetter.Children.Add(btntxt);
            }
        }

        void btntxt_Click(object sender, RoutedEventArgs e)
        {
            Button btn = new Button();
            btn = (Button)sender;

            string link = "/View/Feature2/DrawText/DrawText.xaml?letter=" + btn.Content.ToString();
            NavigationService.Navigate(new Uri(link, UriKind.RelativeOrAbsolute));
        }
    }
}